<!--
Copyright 2017 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the License for the specific language governing permissions and limitations under
the License.
-->

<link rel="import" href="../../components/auth-panel/auth-panel.html">
<link rel="import" href="../../components/datalab-info/datalab-info.html">
<link rel="import" href="../../components/datalab-settings/datalab-settings.html">
<link rel="import" href="../../components/shared-styles/shared-styles.html">
<link rel="import" href="../../components/timeout-panel/timeout-panel.html">
<link rel="import" href="../../modules/settings-manager/settings-manager.html">

<link rel="import" href="../../bower_components/polymer-decorators/polymer-decorators.html">
<link rel="import" href="../../bower_components/app-layout/app-header/app-header.html">
<link rel="import" href="../../bower_components/app-layout/app-toolbar/app-toolbar.html">
<link rel="import" href="../../bower_components/iron-icons/iron-icons.html">
<link rel="import" href="../../bower_components/paper-button/paper-button.html">
<link rel="import" href="../../bower_components/paper-dialog/paper-dialog.html">
<link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">

<dom-module id="datalab-toolbar">
  <template>
    <style include="datalab-shared-styles">
      :host {
        --toolbar-button-dimension: 35px;
      }
      .left, .right {
        flex: 0 0 auto;
      }
      .middle {
        flex: 1 1 auto;
        overflow: hidden;
      }
      .toolbar-title {
        font-size: 18px;
      }
      .title-image {
        height: 30px;
        vertical-align: middle;
      }
      app-header {
        background-color: var(--primary-accent-color);
        color: var(--toolbar-fg-color);
        z-index: 1;
      }
      app-toolbar {
        display: flex;
        height: var(--toolbar-height);
        padding-right: 6px;
        pointer-events: all;
      }
      paper-icon-button {
        margin-right: 16px;
        --paper-icon-button: {
          width: var(--toolbar-button-dimension);
          height: var(--toolbar-button-dimension);
        };
      }
      .title-cloud-datalab {
        font-weight: lighter;
      }
      .account-dropdown {
        background-color: var(--primary-bg-color);
        color: var(--primary-fg-color);
        position: absolute;
        right: 10px;
        top: calc(var(--toolbar-height) + 3px);
        margin: 0px;
        padding: 10px;
        min-width: 250px;
        max-width: 300px;
        box-shadow: 0px 2px 10px 2px var(--box-shadow-color);
        border: 1px solid var(--outline-color);
      }
      datalab-info {
        margin: 20px;
      }
    </style>

    <app-header slot="header" fixed shadow>
      <app-toolbar>
        <div main-title class="left toolbar-title">
          <!--TODO: @yebrahim replace this with SVG version of the logo-->
          <img src="" class="title-image">
        </div>
        <div class="middle">
          <slot name="content"></slot>
        </div>
        <div class="right">
          <paper-icon-button id="infoButton" icon="info"
                             on-click="_infoClicked"></paper-icon-button>
          <paper-icon-button id="settingsButton" icon="settings" on-click="_settingsClicked"
                             hidden="{{!_userSettingsEnabled}}"></paper-icon-button>
          <paper-icon-button id="accountButton" icon="account-circle"
                             on-click="_accountIconClicked">
          </paper-icon-button>
        </div>
      </app-toolbar>
    </app-header>

    <!--Account dropdown dialog. This always shows at the top right corner
    below the toolbar-->
    <paper-dialog id="accountDropdown" class="account-dropdown">
      <auth-panel></auth-panel>
      <timeout-panel id="accountTimeoutPanel" hidden="{{!_timeoutEnabled}}"></timeout-panel>
    </paper-dialog>

    <!--Info dialog. This shows centered in the middle of the window-->
    <paper-dialog id="infoDialog" class="big dialog" with-backdrop>
      <div class="dialog-title">Info</div>
      <div class="dialog-content">
        <datalab-info></datalab-info>
      </div>
      <hr>
      <div class="dialog-footer">
        <paper-button dialog-dismiss>Close</paper-button>
      </div>
    </paper-dialog>

    <!--Settings dialog. This shows centered in the middle of the window-->
    <paper-dialog id="settingsDialog" class="big dialog" with-backdrop>
      <div class="dialog-title">Settings</div>
      <div class="dialog-content">
        <datalab-settings id="settingsElement"></datalab-settings>
      </div>
      <hr>
      <div class="dialog-footer">
        <paper-button dialog-dismiss>Close</paper-button>
      </div>
    </paper-dialog>

  </template>
</dom-module>

<script src="datalab-toolbar.js"></script>
